#1 导入依赖
import requests
from lxml import etree
from bs4 import BeautifulSoup

#2 发送请求和获取响应
html = requests.get('https://www.dushu.com/lianzai/1115_1.html')
print(html.status_code)
html.encoding='utf-8'
html_text = html.text
# print(html_text)


#3 解析html文件，返回一个节点树的对象
# html_selector = etree.HTML(html_text)

#3 换成了beautifulsoup
soup = BeautifulSoup(html.text, "lxml")

#4 获取根节点html的元素
# bookname = html_selector.xpath("//li/div/h3/a/text()")
# print(bookname)

#4 获取根节点html的元素，换成了beautifulsoup，推荐css选择器
# infos = soup.find_all('div', class_="book-info")
# print(infos)

infos = soup.select('.book-info > h3')
print(infos)